﻿using CompanyManageSystem.DLL;
using CompanyManageSystem.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CompanyManageSystem.UI.Repast
{
    public partial class Frm_AddSupplierFinance : BaseXtraForm
    {
        public event EventHandler SaveEvent;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="status"></param>
        public Frm_AddSupplierFinance(EStatus status)
        {
            InitializeComponent();
            this.FStatus = status;
        }

        /// <summary>
        /// 窗体加载完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Frm_AddSupplierFinance_Load(object sender, EventArgs e)
        {
            RepastService rservice = new RepastService();
            SupplierEdit.Properties.DataSource = rservice.GetAllSuppliers();
        }

        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_OK_Click(object sender, EventArgs e)
        {
            RepastService reservice = new RepastService();
            if (this.FStatus == EStatus.Add)
            {
                reservice.AddSupplierFinance((Guid)this.SupplierEdit.EditValue, this.SupplierEdit.Text.Trim(), this.YearMonthsEdit.DateTime, Convert.ToDecimal(this.MoneyEdit.Text.Trim()), this.RemarkEdit.Text.Trim());
                ShowInfo("添加成功!");
            }

            if (SaveEvent != null)
            {
                SaveEvent(null, new EventArgs());
            }
            this.Close();
        }

        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Cancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
